<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>09 侦听属性</title>
</head>
<body>
  <div id="app">
    <input type="text" v-model="firstName"> +
    <input type="text" v-model="lastName"> = {{ fullName }}

  </div>
</body>
<script src="lib/vue.js"></script>
<script>
  new Vue({
    el: '#app',
    data: {
      firstName: '',
      lastName: '',
      fullName: ''
    },
    watch: {
      firstName (newVal, oldVal) {
        console.log(newVal, oldVal)
        this.fullName = newVal + this.lastName
      },
      lastName (newVal, oldVal) {
        console.log(newVal, oldVal)
        this.fullName = this.firstName + newVal
      }
    }
  })
</script>
</html>
